package com.yuwubao.uav.tool.service.impl;

import com.yuwubao.framework.bean.PageData;
import com.yuwubao.uav.tool.entity.AdType;
import com.yuwubao.uav.tool.entity.ThemeAd;
import com.yuwubao.uav.tool.entity.ThemeAdType;
import com.yuwubao.uav.tool.mapper.AdMapper;
import com.yuwubao.uav.tool.service.AdService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AdServiceImpl implements AdService {
    @Resource
    private AdMapper adMapper;

    @Override
    public List<PageData> getAdTypes(PageData pd) {
        return adMapper.getAdTypes(pd);
    }

    @Override
    public Integer getAdTypesNum(PageData pd) {
        return adMapper.getAdTypesNum(pd);
    }

    @Override
    public void editType(AdType adType) {
        adMapper.editType(adType);
    }

    @Override
    public void delType(int id) {
        adMapper.delType(id);
    }

    @Override
    public void editState(int id) {
        adMapper.editState(id);
    }

    @Override
    public void editThemeAd(ThemeAd ad) {
        adMapper.editThemeAd(ad);
    }

    @Override
    public List<PageData> getThemeAds(PageData pd) {
        return adMapper.getThemeAds(pd);
    }

    @Override
    public Integer getThemeAdsNum(PageData pd) {
        return adMapper.getThemeAdsNum(pd);
    }

    @Override
    public void delThemeAd(int id) {
        adMapper.delThemeAd(id);
    }

    @Override
    public void editThemeAdState(int id) {
        adMapper.editThemeAdState(id);
    }

    @Override
    public List<PageData> getAllType() {
        return adMapper.getAllTypes();
    }

    @Override
    public List<PageData> getThemeAdsByType(int id) {
        return adMapper.getThemeAdsByType(id);
    }

    @Override
    public PageData getThemeAdById(int id) {
        return adMapper.getThemeAdById(id);
    }

    @Override
    public void clientThemeAd(int id) {
        adMapper.clientThemeAd(id);

    }

    @Override
    public List<PageData> getParentAds(PageData pd) {
        return adMapper.getParentAds(pd);
    }

    @Override
    public Integer getParentAdsNum(PageData pd) {
        return adMapper.getParentAdsNum(pd);
    }

    @Override
    public void editParentAdType(ThemeAdType type) {
        adMapper.editParentAdType(type);
    }

    @Override
    public void delParentAdType(int id) throws Exception {
        int child = adMapper.getChildById(id);
        if (child!=0){
            throw new Exception("存在下级子分类,不能删除");
        }
        adMapper.delParentAdType(id);
    }

    @Override
    public List<PageData> getChildTypeById(int id) {
        return adMapper.getChildTypeById(id);
    }

    @Override
    public PageData getAdTypeByid(int id) {
        return adMapper.getTypeById(id);
    }

    @Override
    public List<PageData> getThemeAdsByPd(PageData pd) {
        return adMapper.getThemeAdsByPd(pd);
    }

    @Override
    public Integer getThemeAdsNumByPd(PageData pd) {
        return adMapper.getThemeAdsNumByPd(pd);
    }
}
